from rest_framework import serializers
from .models import Area, AreaImage
from ..products.models import Category


class AreaImageSerializer(serializers.ModelSerializer):
    class Meta:
        model = AreaImage
        fields = ['id', 'file', 'name', 'created_at']


class AreaCategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = Category
        fields = ['id', 'name', 'parent_id']


class AreaSerializer(serializers.ModelSerializer):
    images = AreaImageSerializer(many=True, read_only=True)
    category = AreaCategorySerializer(read_only=True)

    class Meta:
        model = Area
        fields = ['id', 'title', 'description', 'images', 'video_links', 'category']


#
class AreaListSerializer(serializers.ModelSerializer):
    images = AreaImageSerializer(many=True, read_only=True)
    category = AreaCategorySerializer(read_only=True)

    class Meta:
        model = Area
        fields = ['id', 'title', 'category', 'images']
